<template>
  <div>
    <t-form
      ref="form"
      class="base-form"
      :data="formData"
      :rules="FORM_RULES"
      label-align="top"
      :label-width="100"
      @reset="onReset"
      @submit="onSubmit"
    >
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>
      <t-form-item label="" name="">
        <t-input v-model=""></t-input>
      </t-form-item>

      <t-form-item label="" name="">
        <t-button theme="primary" class="form-submit-confirm" type="submit"> 提交 </t-button>
      </t-form-item>
    </t-form>
  </div>
</template>

<script lang="ts">
export default {
  name: 'TransferFormBase',
};
</script>
<script setup lang="ts">
import { ref } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
import { FORM_RULES, INITIAL_DATA } from '../constants';

const formData = ref({ ...INITIAL_DATA });

const onReset = () => {
  MessagePlugin.warning('取消新建');
};
const onSubmit = ({ validateResult }) => {
  if (validateResult === true) {
    MessagePlugin.success('新建成功');
  }
};
const beforeUpload = (file) => {
  if (!/\.(pdf)$/.test(file.name)) {
    MessagePlugin.warning('请上传pdf文件');
    return false;
  }
  if (file.size > 60 * 1024 * 1024) {
    MessagePlugin.warning('上传文件不能大于60M');
    return false;
  }
  return true;
};
const handleFail = ({ file }) => {
  MessagePlugin.error(`文件 ${file.name} 上传失败`);
};
// 用于格式化接口响应值，error 会被用于上传失败的提示文字；url 表示文件/图片地址
const formatResponse = (res) => {
  return { ...res, error: '上传失败，请重试', url: res.url };
};
</script>

<style></style>
